package com.linkage.bss.crm.packagemgr.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import com.linkage.bss.commons.dao.Page;
import com.linkage.bss.commons.dao.ibatis.BaseDAO;
import com.linkage.bss.crm.packagemgr.dao.IPackageManagerDAO;
import com.linkage.bss.crm.packagemgr.model.Package;
import com.linkage.bss.crm.packagemgr.model.PackageParameter;

/**
 *
 * 包管理 DAO
 * @author  olns
 * @version  [版本号, 2013-4-28]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class PackageManagerDAOImpl extends BaseDAO implements IPackageManagerDAO {

	public List<Package> getPackageByCond(Map map, Page page) {
		return queryForPageList("PackageManager.getPackageByCond", map, page);
	}

	public int getPackageByCondCount(Map map) {
		return (Integer) getSqlMapClientTemplate().queryForObject("PackageManager.getPackageByCondCount", map);
	}

	public Package getPackageById(Long packageID) {
		Map map = new HashMap();
		map.put("packageId", packageID);
		return (Package) getSqlMapClientTemplate().queryForObject("PackageManager.getPackageByCond", map);

	}

	public void saveActivitySecondary(JSONObject data) {
		getSqlMapClientTemplate().insert("PackageManager.saveActivitySecondary", data);
	}

	@SuppressWarnings("unchecked")
	public List<PackageParameter> getPackageParamByID(Long packageID) {
		return getSqlMapClientTemplate().queryForList("PackageManager.getPackageParam", packageID);
	}

	public void insertPackageInfo(Package pack) {
		getSqlMapClientTemplate().insert("PackageManager.insertPackageInfo", pack);

	}

	public void insertPackageParameter(PackageParameter packParam) {

		getSqlMapClientTemplate().insert("PackageManager.insertPackageParam", packParam);
	}

	public void updatePackageInfo(Package pack) {
		getSqlMapClientTemplate().update("PackageManager.updatePackage", pack);

	}

	public void delPackageParamByPackage(Long packageId) {

		getSqlMapClientTemplate().delete("PackageManager.delPackageParam", packageId);
	}

	public void delPackageById(Long packageId) {
		getSqlMapClientTemplate().delete("PackageManager.delPackageById", packageId);
	}

}
